package com.service.impl;

import com.mapper.PunchRecordMapper;
import com.pojo.view.PunchRecord;
import com.service.PunchRecordService;
import com.util.SqlSessionFactoryUtils;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

import java.util.ArrayList;
import java.util.List;

public class PunchRecordServiceImpl implements PunchRecordService {

    SqlSessionFactory sqlSessionFactory = SqlSessionFactoryUtils.getSqlSessionFactory();

    @Override
    public List<PunchRecord> getAllPunchRecord(String username) {
        SqlSession sqlSession = sqlSessionFactory.openSession();
        PunchRecordMapper mapper = sqlSession.getMapper(PunchRecordMapper.class);
        List<PunchRecord> punchRecordList = mapper.getAllByUsername(username);

        sqlSession.close();
        return punchRecordList;
    }
}
